package com.ruoyi.wechat.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.wechat.domain.Order;
import com.ruoyi.wechat.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wechat/order")
public class WxOrderController extends BaseController {
    @Autowired
    private IOrderService orderService;

    @GetMapping("/list")
    public TableDataInfo list(Order order)
    {
        List<Order> list = orderService.selectOrderAndDetailList(order);
        return getDataTable(list);
    }
    @PutMapping
    public AjaxResult edit(@RequestBody Order order)
    {
        return toAjax(orderService.updateOrder(order));
    }


    @PostMapping
    public AjaxResult add(@RequestBody Order order)
    {
        return toAjax(orderService.insertOrder(order));
    }

}
